<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 订单回访
 *
 * @author linshunwei
 *
 * @SWG\Model(id="OrderFollow")
 * @SWG\Property(name="id",type="integer",description="主键索引")
 * @SWG\Property(name="order_id",type="string",description="订单ID")
 * @SWG\Property(name="content",type="string",description="回访内容")
 * @SWG\Property(name="adviser_id",type="integer",description="回访人")
 */
class OrderFollow extends Model
{

	public static function boot()
	{
		parent::boot();
		static::created(function ($model) {

		});

		static::saving(function ($model) {

//			$first = OrderFollow::where('order_id', $model->order_id)->where('first', 'Yes')->first();
//
//			if (is_null($first)) {
//				$model->first = 'Yes';
//			}
		});
	}

	/**
	 *  相关操作人信息
	 */
	public function admin()
	{
		return $this->belongsTo('App\Models\Admin', 'admin_id');
	}

	/**
	 *  订单
	 */
	public function orders()
	{
		return $this->belongsTo('App\Models\Order', 'order_id');
	}
}
